<template>
	<view>
		<view style="margin-bottom: 80upx;" v-if="datasa">	
			<!-- <view class="flex alcenter space" style="margin-bottom: 30upx;">
				<view class="flex alcenter">
					<image style="width: 40rpx;height: 40rpx;" src="@/static/shop/cnxh.png"></image>
					<text class="ft16 ftw600 cl-main ml15">猜你喜欢</text>
				</view>
				<navigator url="/pages/client/shop/list">
				<view class="ft14 cl-notice">更多</view>
				</navigator>
			</view> -->
			<scroll-view scroll-x class="bg-white nav " scroll-with-animation :scroll-left="scrollLeft">
				<view class="cu-item" :class="-1==TabCur?'text-green cur':''"  @tap="tabSelect" :data-id="-1" :data-e="item.id">
					<text class="ft14 ftw200 cl-notice" :class="-1==TabCur?'text-green cur':''" >全部分类</text>
				</view>
				<view class="cu-item" :class="index==TabCur?'text-green cur':''" 
				v-for="(item,index) in datasa" :key="index" @tap="tabSelect" :data-id="index" :data-e="item.id">
					<text class="ft14 ftw200 cl-notice" :class="index==TabCur?'text-green cur':''" >{{item.title}}</text>
				</view>
			</scroll-view> 
				<block v-for="(value,key) in shoparr" :key="key">
				<view @click="detail(value.id)" style="position: relative;" class="box pd12_10 flex alcenter mb16 hezi" >
					<image mode="aspectFill" class="tuan-product-l" :src="value.img"></image>
					<!-- <view class="btn-mini" style="position: absolute; top: 40upx; left: 280upx; border-radius: 10upx;font-size: 18upx;width: 60upx; height: 36upx;" :style="getBtnStyle">{{value.lxname}}</view> -->
					<view class="tuan-product-r pl15">
						<view class="ft14 cl-main text-over2">{{value.title}}</view>
						<view class="ft12 cl-notice text-over2">{{value.introduce}}</view>
						<view class="mt10">
							<text class="mr5 ft14 cl-orange ftw600">¥{{value.money}}</text>
							<text class="ml5 ft10 cl-notice text-line">¥{{value.money_primary}}</text>
						</view>
						<view class="mt10 flex space alcenter">
							<text class="ft12 cl-notice" v-if="value.stock">库存 {{value.stock}}</text>
							<text  class="coupon-tip" style="float: right;background: none;color: #363B4D;" v-if="value.sales">销量{{value.sales}}</text>
						</view>
						<view class="mt10 flex space alcenter" v-if="value.end_time_text">
							<view class="ft12 cl-orange cl-notice">{{value.end_time_text}}</view>
						</view>
						<view class="mt10 flex space alcenter" v-if="value.team_rebate>0 && bus_id > 0" >
							<view class="ft12 cl-orange cl-notice">我的收益:¥{{value.team_rebate}}</view>
						</view>
					</view>
				</view>
				</block>
		</view>
		<view class="home-main">
			<com-copyright></com-copyright>
		</view>
		<dialog-birthday v-if="showBirthday" @closed="showBirthday = false"></dialog-birthday>
		<dialog-login v-if="showLogin" @loginYes="loginYes" @closed="showLogin = false"></dialog-login>
		<dialog-qrcode v-if="showQrcode" @closed="showQrcode = false"></dialog-qrcode>
		<dialog-couponshareget @loginAct="showLoginCouponShareGet" v-if="showCouponShareGet" @closed="showCouponShareGet = false"></dialog-couponshareget>
	</view>
</template>

<script>
	export default{
		props: ['datasa'],
		data(){
			return {
				isLogin:false,
				showBirthday:false,
				showLogin:false,
				showQrcode:false,
				showCouponShareGet:false,
				TabCur:-1,
				scrollLeft: 0,
				shoparr:[],
				page:1,
				bus_id:0,
			}
		},

		mounted(){
			// this.fenlei(1)
			// setTimeout(()=>{
			// 	this.showCouponShareGet = true;	
			// },1000);
			this.bus_id = uni.getStorageSync("userinfo").bus_id;
		},
		
		methods:{
			fenlei(e){
				this.$ajax('post','cate/goods_list',{
					page:this.page,
					id:this.TabCur>-1?e:''
				}).then(res=>{
					this.shoparr.push(...res.data)
				})
			},
			xiala(){
				let id = this.TabCur>-1? this.datasa[this.TabCur].id :''
				this.page++;
				this.fenlei(id)
			},
			//'/pages/client/tuan/detail?id='+value.id
			tabSelect(e) {
				this.TabCur = e.currentTarget.dataset.id;
				this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60;
				this.page=1;
				this.shoparr=[];
				this.fenlei(e.currentTarget.dataset.e)
			},
			detail(id,lx){
				uni.navigateTo({
					url:'/pages/client/shop/product?id='+id
				})
			},
			showLoginAct(){
				this.showLogin = true;
			},
			showLoginCouponShareGet(){
				this.showLogin = true;
			},
			loginYes(){
				
			}
		}
	}
</script>

<style>
	.nav .cu-item.cur {
		border-bottom: 4upx solid;
	}
	
	.nav .cu-item {
		height: 90upx;
		display: inline-block;
		line-height: 90upx;
		margin: 0 10upx;
		padding: 0 20upx;
	}
	.text-green{
		color: rgb(1, 183, 80);
	}
	.nav .cu-item.cur {
		border-bottom: 4upx solid;
	}
	.nav {
		background: #fff;
		white-space: nowrap;
	}
	.home-header{
		height: 304rpx;
		width: 100%;
		position: relative;
		background: #363B4D;
		border-radius: 0rpx 0rpx 48rpx 48rpx;
	}
	.hezi{
		width: 92%;
		margin: 20rpx auto 0;
	}
	.home-main{
		width: 100%;
		position: relative;
		margin-top: -156rpx;
		padding: 0 30rpx;
	}
	.home-mendian{
		width: 100%;
		height: 84rpx;
		background:rgba(255,255,255,0.1);
		border-radius: 42rpx;
	}
	.tuan-product-l{
		width: 240rpx;
		height: 240rpx;
		border-radius: 16rpx;
		background: #F2F2F2;
	}
	.tuan-product-r{
		width: calc(100% - 240rpx);
	}
	
</style>
